﻿using HelenServer.UserCenter.Contracts;

namespace HelenServer.UserCenter.Controllers;

[ApiController]
[Route("[controller]")]
public class PositionController : ControllerBase
{
    private readonly IPositionService _service;

    public PositionController(IPositionService service)
    {
        _service = service;
    }

    [HttpPost]
    public async Task<OperationResult<int>> AddAsync([FromBody] PositionCreateModel model)
    {
        var operation = HttpContext.GetOperation(model);

        return await _service.AddAsync(operation, HttpContext.RequestAborted);
    }

    [HttpPost("batch")]
    public async Task<OperationResult<int>> AddRangeAsync([FromBody] IEnumerable<PositionCreateModel> models)
    {
        var operation = HttpContext.GetOperation(models);

        return await _service.AddRangeAsync(operation, HttpContext.RequestAborted);
    }
}